﻿using System.Collections.Generic;
using System.Data.Entity;
using Moonwish.Core.DataAccess;
using Moonwish.Foundation.DataEntity;

namespace Moonwish.Foundation.DataAccess.SqlServer.AppModuleCmd
{
    public class AddCommand : EntityCommand<V_FDT_App>
    {
        public AddCommand(DbContext dbContext, List<V_FDT_App> items, string userId) : base(dbContext, items, userId)
        {
        }

        public override void Execute()
        {
            var appSet = DbContext.Set<T_FDT_App>();
            var pageSet = DbContext.Set<T_FDT_AppPage>();
            foreach (var item in Items)
            {
                var newApp = new T_FDT_App
                {
                    Name = item.Name,
                    XapName = item.XapName,
                    InstallTime = item.InstallTime,
                    IsInternal = item.IsInternal,
                    Author = item.Author,
                    Copyright = item.Copyright
                };
                appSet.Add(newApp);
                foreach (var page in item.V_FDT_AppPages)
                {
                    var newPage = new V_FDT_AppPage
                                      {
                                          
                                      };
                }
            }
            DbContext.SaveChanges();
        }
    }
}
